export const tmplStr2 = `import React from "react";

/**
* 
* @param record 当前卡片数据
* @param config 配置了propName的属性配置
* @param actionProps 操作对象: defaultNode-默认渲染的操作节点，actions: 操作项配置数据，dispatch-操作点击调用
* dispatch(...action, data: record)
* @returns {JSX.Element}
* @constructor
*/
function CardContentTmpl({record = {}, config = CardContentTmpl.config, actionProps = {}} = {}) {
  const {defaultNode} = actionProps;
  const attrs = Object.keys(config).map(key => {
    return {...config[key]}
  });
  const dataItems = attrs.filter(
    (attr) =>
      !['title', 'img']
        .filter((key) => key)
        .includes(attr?.placeKey),
  );
  return (
    <div>
     {record[config.title.propName] != null && (
       <header title={record[config.title.propName]}>
         {record[config.title.propName]}
         {defaultNode}
       </header>
     )}
      <main>
        <div>
          {dataItems.map((item, index) => {
            return (
              <div key={item.id || index} >
                <label>{item.label}：</label>
                <span title={record[item.propName]}>{record[item.propName]}</span>
              </div>
            );
          })}
        </div>
       
      </main>
    </div>
  );
}

CardContentTmpl.tmplName = '默认模板2';
CardContentTmpl.config = {
  title: {
    placeKey: 'title',
    placeText: '位置1',
    label: '模板2-标题',
    typeValue: 'obj',
    propName: '',
  },
  data1: {
    placeKey: 'data1',
    placeText: '位置2',
    label: '模板2-数据1',
    typeValue: 'obj',
    propName: '',
  },
  data2: {
    placeKey: 'data2',
    placeText: '位置3',
    label: '模板2-数据2',
    typeValue: 'obj',
    propName: '',
  },
  data3: {
    placeKey: 'data3',
    placeText: '位置4',
    label: '模板2-数据3',
    typeValue: 'obj',
    propName: '',
  },
  data4: {
    placeKey: 'data4',
    placeText: '位置5',
    label: '模板2-数据4',
    typeValue: 'obj',
    propName: '',
  },
  data5: {
    placeKey: 'data5',
    placeText: '位置6',
    label: '模板2-数据5',
    typeValue: 'obj',
    propName: '',
  }
}

export default CardContentTmpl`;
